<?php

namespace apiend\modules\passport\controllers;

use Yii;
use apiend\components\Controller;
use apiend\modules\passport\models\SecuritySmsForm;

/**
 * 短信接口
 * @author emhome <emhome@163.com>
 * @since 2.0
 */
class SmsController extends Controller {

    /**
     * @inheritdoc
     */
    protected function verbs() {
        return [
            '*' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    /**
     * 普通类验证码
     * @return mixed
     */
    public function actionReset() {
        $model = new SecuritySmsForm();
        $model->user_id = $this->uid;
        $model->scope = SecuritySmsForm::SCOPE_RESET;
        return $model->send();
    }

    /**
     * 安全类短信
     * @return mixed
     */
    public function actionAccount() {
        $model = new SecuritySmsForm();
        $model->user_id = $this->uid;
        $model->scope = SecuritySmsForm::SCOPE_ACCOUNT;
        return $model->send();
    }

}
